/* 
 * File:   ChildServer.h
 * Author: faraj
 *
 * Created on October 4, 2009, 1:20 AM
 */

#include "Client.h"
#include "../CTools/CTools.h"
#include "vector"
#include "GlobalData.h"
#include "RequestHandler.h"
#include "ClientList.h"

#ifndef _CHILDSERVER_H
#define	_CHILDSERVER_H

static void* ServerService(void* args)
{   
    Client *client = (Client*) args;
    
    CSocket *skt = client->getSocket();
    
    fd_set rset;
    
    int maxfdp1 = skt->getSockfd() + 1;
    
    FD_SET(skt->getSockfd(),&rset);
    
    int result;
    
    string *val;
 
    while(client->getSocket()->isConnected())
    {
        result = Select(maxfdp1,&rset,NULL,NULL,NULL);
        if(!(result==1 && handleRequest(client)))
        {
            clientList.removeClient(client);
        }
    }
}



#endif	/* _CHILDSERVER_H */

